home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Thread Manager / Thread Manager 2.1.1d1+ / ThreadedSort / Sprocket / Lib / SplashWindow.cp < prev    next >
Encoding:
Text File  |  1995-04-28  |  2.1 KB  |  85 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SplashWindow.cp
  3.  
  4.     Contains:    a simple splash screen window
  5.                 
  6.     Written by: Dave Falkenburg
  7.     
  8.     Copyright:    © 1993-94 by Dave Falkenburg, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.          <6>    11/16/94    DRF        Add (StringPtr) cast to make PPCC happier.
  13.          <5>    11/12/94    DRF        Use NewColorOrBlackAndWhiteWindow.
  14.          <4>     11/8/94    DRF        Deal with a missing splash picture.
  15.          <3>     9/27/94    DRF         AppLib.h is now Sprocket.h
  16.          <2>      9/9/94    DRF        Reordered headers and removed redundant #includes.
  17.  */
  18.  
  19. #include "Sprocket.h"
  20. #include "SplashWindow.h"
  21.  
  22. #include <ToolUtils.h>
  23. #include <Resources.h>
  24.  
  25.  
  26. TSplashWindow::TSplashWindow()
  27.     {
  28.     this->CreateWindow(kNormalWindow);
  29.     }
  30.  
  31.  
  32. TSplashWindow::~TSplashWindow()
  33.     {
  34.     if (fSplashPicture)
  35.         DisposeHandle((Handle) fSplashPicture);
  36.  
  37.     this->Close();
  38.     }
  39.  
  40.  
  41. WindowPtr
  42. TSplashWindow::MakeNewWindow(WindowPtr behindWindow)
  43.     {
  44.     GrafPtr        oldPort;
  45.     Rect        splashPictRect,windowRect;
  46.     WindowPtr    splashWindow;
  47.     
  48.     GetPort(&oldPort);
  49.  
  50.     fSplashPicture = GetPicture(kSplashPictureID);
  51.     
  52.     if (fSplashPicture)
  53.         {
  54.         MoveHHi((Handle) fSplashPicture);                        //    get it out of the way
  55.         splashPictRect = (**fSplashPicture).picFrame;
  56.         }
  57.     else
  58.         SetRect(&splashPictRect,0,0,0,0);
  59.         
  60.     //    normalize the rectangle
  61.     OffsetRect(&splashPictRect,-splashPictRect.left,-splashPictRect.top);
  62.  
  63.     //    center it on the main screen
  64.     windowRect = splashPictRect;
  65.     OffsetRect(&windowRect,((qd.screenBits.bounds.right-windowRect.right) >> 1),((qd.screenBits.bounds.bottom-windowRect.bottom) >> 1));
  66.     
  67.     splashWindow = NewColorOrBlackAndWhiteWindow(nil,&windowRect,(StringPtr) "\p",false,dBoxProc,behindWindow,false,(long) this);
  68.  
  69.     if (fSplashPicture)
  70.         {
  71.         DetachResource((Handle) fSplashPicture);    // need to do so we don’t botch the resource map after closing
  72.         SetWindowPic(splashWindow,fSplashPicture);    // in case an Alert comes up
  73.         }
  74.         
  75.     ShowWindow(splashWindow);
  76.     SetPort(splashWindow);
  77.     BeginUpdate(splashWindow);                    //    avoid a flashing update event later
  78.         if (fSplashPicture)
  79.             DrawPicture(fSplashPicture,&splashPictRect);
  80.     EndUpdate(splashWindow);                    //    avoid a flashing update event later
  81.  
  82.     SetPort(oldPort);
  83.     return splashWindow;
  84.     }
  85.